home *** CD-ROM | disk | FTP | other *** search
/ Netware Super Library / Netware Super Library.iso / drivers / nics / pktdrv7 / movemem.asm < prev    next >
Encoding:
Assembly Source File  |  1990-07-13  |  830 b   |  23 lines

  1. movemem:
  2. ;does the same thing as "rep movsb", only 50% faster.
  3. ;moves words instead of bytes, and handles the case of both addresses odd
  4. ;efficiently.  There is no way to handle one address odd efficiently.
  5. ;This routine always aligns the source address in the hopes that the
  6. ;destination address will also get aligned.  This is from Phil Karn's
  7. ;code from ec.c, a part of his NET package.  I bummed a few instructions
  8. ;out.
  9.     jcxz    movemem_cnte        ; If zero, we're done already.
  10.     test    si,1            ; Does source start on odd byte?
  11.     jz    movemem_adre        ; Go if not
  12.     movsb                ; Yes, move the first byte
  13.     dec    cx            ; Count that byte
  14. movemem_adre:
  15.     shr    cx,1            ; convert to word count
  16.     rep    movsw            ; Move the bulk as words
  17.     jnc    movemem_cnte        ; Go if the count was even
  18.     movsb                ; Move leftover last byte
  19. movemem_cnte:
  20.     ret
  21.  
  22.  
  23.